package xiaohu.day1.HJ17;

import java.util.Scanner;

public class Main2 {
    static int x;
    static int y;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            myInit();
            String str = in.nextLine();
            str.toUpperCase();
            String[] split = str.split(";");
            for (int i = 0; i < split.length; i++) {
                String s= split[i].trim();
                moveWSAD(s);
            }
            System.out.println(x+","+y);
        }
    }

    private static void moveWSAD(String s) {
        String n=null;
        if (s.length() >= 2) {
             n= s.substring(1);
        }
        if (n!=null && n!="" && isInteger(n)) {
            int dist = Integer.parseInt(n);
            switch (s.charAt(0)) {
                case 'W': y+=dist; break;
                case 'S': y-=dist; break;
                case 'A': x-=dist; break;
                case 'D': x+=dist;
            }
        }
    }

    private static boolean isInteger(String n) {
        try {
            int i = Integer.parseInt(n);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    private static void myInit() {
        x=0;
        y=0;
    }
}
